package com.baizhi.hospital.service.impl;

import com.baizhi.hospital.annotation.LogAnnotation;
import com.baizhi.hospital.dao.DrugDao;
import com.baizhi.hospital.entity.Drug;
import com.baizhi.hospital.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DrugServiceImpl implements DrugService {
    @Autowired(required = false)
    private DrugDao drugDao;

    @Override
    //@LogAnnotation(value = "查询药品信息",type = "selectDrug")
    public Map selectDrugByPage(int page, int limit, String name) {
        if(name==null||name==""){
            name=null;
        }else{
            name="%"+name+"%";
        }
        int offset=(page-1)*limit;
        List<Drug> drugs = drugDao.selectDrugByPage(offset, limit, name);
        int count = drugDao.selectCount(name);
        Map map=new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("data",drugs);
        map.put("count",count);
        return map;
    }
}
